<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //浅层拷贝
        // var a={age:18};
        // var b=a;
        // a.age=20;
        // console.log(a,b);

        //深拷贝
        // console.log(JSON.parse(JSON.stringify({name:'li'})));
        
        var a={age:18};
        var b=JSON.parse(JSON.stringify(a));
        a.age=20;
        console.log(a,b);

    </script>
</body>
</html>